package com.dlc.felear.xiaoensale.helper;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;

import org.apache.commons.lang3.StringEscapeUtils;

public class JsonHelper {
    public static <T> T parserJson(String json, Class<T> cls) {
        return JSONObject.parseObject(json, cls);
    }
    public static <T> T parserJson(String json, TypeReference<T> type) {
        return JSONObject.parseObject(json,type);
    }
    public static <T> T parserJson(String json, T type) {
        return JSONObject.parseObject(json,new TypeReference<T>(){});
    }
    public static String unescapeJava(String json) {
        return StringEscapeUtils.unescapeJava(json);
    }
    public static String toJson(Object o) {
        return JSONObject.toJSONString(o);
    }
}
